﻿using System;
using System.Collections.Generic;

using System.Text;
using System.Runtime.InteropServices;


/*
 *  http://www.hdfgroup.org/HDF5/doc/HL/RM_H5PT.html#H5PTopen
 */
 
namespace H5CSharp.DllImport
{
    using hid_t = System.Int32;
    using herr_t = System.Int32;
    using hsize_t = System.UInt64;
    using hssize_t = System.Int64;
    using hunsigned = System.UInt32;

    using hbool_t = System.UInt32;
    using htri_t = System.Int32;
    using ssize_t = System.Int64;

    using haddr_t = System.UInt64;

    using uint32_t = System.UInt32;
    using uint64_t = System.UInt64;

    using H5O_msg_crt_idx_t = System.UInt32;

    using size_t = System.UInt32;

    using off_t = System.Int32;

    using H5E_major_t = System.Int32;
    using H5E_minor_t = System.Int32;

    using time_t = System.Int64;
    using H5Z_filter_t = System.Int32;  

    public static class H5PT
    {
        #region Creation and Opening
        [DllImport("hdf5_hldll.dll")]
        public static extern hid_t H5PTcreate_fl(hid_t loc_id, [In][MarshalAs(UnmanagedType.LPStr)] string dset_name, hid_t dtype_id, hsize_t chunk_size, int compression);

        [DllImport("hdf5_hldll.dll")]
        public static extern hid_t H5PTopen( hid_t loc_id, [In][MarshalAs(UnmanagedType.LPStr)] string dset_name );

        [DllImport("hdf5_hldll.dll")]
        public static extern herr_t H5PTclose(hid_t table_id);

        #endregion Creation and Opening

        #region Storage
        
        [DllImport("hdf5_hldll.dll")]
        public static extern herr_t H5PTappend(hid_t table_id, size_t nrecords, IntPtr data);

        #endregion Storage
       
        #region Table Index
        
        [DllImport("hdf5_hldll.dll")]
        public static extern herr_t H5PTcreate_index(hid_t table_id);

        [DllImport("hdf5_hldll.dll")]
        public static extern herr_t H5PTset_index(hid_t table_id, hsize_t pt_index);

        #endregion Table Index

        #region Retrieval

        [DllImport("hdf5_hldll.dll")]
        public static extern herr_t H5PTread_packets(hid_t table_id, hsize_t start, size_t nrecords, IntPtr data);

        [DllImport("hdf5_hldll.dll")]
        public static extern herr_t H5PTget_next(hid_t table_id, size_t nrecords, IntPtr data);
        
        #endregion Retrieval

        #region Query

        [DllImport("hdf5_hldll.dll")]
        public static extern herr_t H5PTget_num_packets(hid_t table_id, out hsize_t nrecords);

        [DllImport("hdf5_hldll.dll")]
        public static extern herr_t H5PTis_valid(hid_t table_id);

        #endregion Query

    }
}
